#include "guiterm.hpp"
#ifndef BACKENDCONNECTION_HPP
#define BACKENDCONNECTION_HPP
#include <QProcess>
#include "StreamBuffer.hpp"

class BackendConnection
	:public QObject
{
	Q_OBJECT
public:
	BackendConnection();
	~BackendConnection();
	
	void sendData(const char *data, int len);
	ServerConnection *getFirstHost();
	bool isIdle();
	
signals:
	void idle();
	
protected slots:
	void started();
	void readReady();
	void finished(int code, QProcess::ExitStatus status);
	void bytesWritten(qint64 size);
	
	void disconnected(bool error, QString message);
	
protected:
	void attemptWrite();
	
	QProcess *child;
	ServerConnection *host;
	StreamBuffer writeBuf;
};

#endif
